<!--
 * @Author: your name
 * @Date: 2021-07-20 16:46:03
 * @LastEditTime: 2021-10-15 13:48:28
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \usp-osm-frondend\src\views\orderCenter\deliveryOrder\dialog\logistics.vue
-->
<template>
  <el-dialog
    title="物流信息"
    append-to-body
    :visible.sync="dialogVisible"
    :close-on-click-modal="false"
    :close-on-press-escape="false"
    :wrapperClosable="false"
    destroy-on-close
    top="0"
    width="40%"
    center
  >
    <div class="content" v-loading="pageLoading" element-loading-text="loading">
      <div style="margin-bottom: 15px">物流公司：{{ datas.supplierName }}</div>
      <div style="margin-bottom: 15px">物流单号：{{ datas.logisticsNo }}</div>
      <el-timeline>
        <el-timeline-item v-if="datas.customerAddress">
          <div>{{ datas.customerAddress.title + ' ' + datas.customerAddress.totalAddress }}</div>
          <div>{{datas.customerAddress.contactMobile}}</div>
        </el-timeline-item>
        <el-timeline-item
          v-for="(activity, index) in datas.nodeList"
          :key="index"
          :timestamp="activity.nodesDate | timestampToChange('time')">
          {{getDictionaryNameByCode('LOGISTICSSTATUS', activity.logisticsStatus)  + ' ' + activity.logisticsDescription}}
        </el-timeline-item>
      </el-timeline>
      <div slot="footer" style="text-align: right">
        <el-button @click="close">关闭</el-button>
      </div>
    </div>
  </el-dialog>
</template>
<script>
import { getDeveryLogistics } from '@/api/order'
import { common } from '@/mixins/common'
import { mapGetters } from 'vuex'
export default {
  name: 'logisticsDialog',
  mixins: [common],

  data () {
    return {
      pageLoading: true,
      dialogVisible: false,
      activities: [],
      datas: {}
    }
  },
  computed: {
    ...mapGetters(['lookupItems'])
  },
  methods: {
    getActivities (id) {
      this.pageLoading = true
      getDeveryLogistics(id).then(res => {
        if (res) {
          if (Number(res.code) === 1) {
            this.datas = res.obj
          }
          this.pageLoading = false
        }
      })
    },
    open (id) {
      this.dialogVisible = true
      this.getActivities(id)
    },
    close () {
      this.dialogVisible = false
      this.pageLoading = true
      this.activities = []
    }
  }
}
</script>
